1. Field of the Invention
The present invention relates to the field of computer systems, and more particularly to a method and apparatus for providing serialization support for a computer system or system resource, such as for a computer application program which requires sequencing of data.
2. Description of the Related Art
In the operation of computer systems, computer application programs often require serialization of the data they are operating on such that the data is handled in a particular sequence. It is very important in some application programs to maintain the sequence and/or the consistency of the data being handled.
Any application program that updates resources may fail while it has an active unit of work in progress. A unit of work is a series of operations performed by an application between two points of consistency. If the application has a requirement for sequencing of data and/or consistency of data then it may require that before the application can restart, the unit of work that was in progress at the time of failure is either completely rolled back or completely rolled forward.
A unit of work is rolled back when the transaction is stopped and the application is returned to its previous state prior to the commencement of the unit of work. A unit of work is rolled forward when an application recovers from a disaster, such as a power failure, by reading a transaction log and re-executing all instructions or by using other techniques to return the application to the state before the disaster in order that the unit of work can continue and, once completed, be committed.
As an example, the application program may perform units of work on a resource manager, such as a queue manager for managing communication between application programs running on different computers in a network. However, this disclosure is applicable to any application that has a requirement for sequencing of data and consistency of data.
Known serialization techniques for programs are known in the art as locking or latching. In the following, the term xe2x80x9clocksxe2x80x9d is used to cover locks and latches.
Known locking methods use a token, sometimes called a lock name, derived by the application programs and representing the process to be serialized. The application program requests ownership of the lock by passing the lock name to a specialised program called a lock manager. When the process is complete, the application releases ownership of the lock, again by passing the lock name to the lock manager program.
When the application requests ownership of a lock, if the lock is already owned by another application or by another copy of the same application then the lock manager either refuses to assign ownership, delays assigning ownership until the previous owner has released ownership, or grants shared ownership of the lock. Which of these it does depends on the lock manager implementation and/or on additional parameters passed by the application and/or on a lock definition process independent of the programs involved.
If an application program fails while holding ownership of a lock, its lock ownership can be released by the lock manager (as in the Enqueue/Dequeue ENQ/DEQ mechanism) or its ownership can be remembered by the lock manager (as in the lock management facilities provided with IBM Corporation""s OS/390 operating system""s cross-system extended services (XES)) so that other copies of the program and/or other programs needing the lock vary their mode of operation to take into account the failed lock holder.
In cases where a process is performed cooperatively and in parallel by several copies of a program, known locking methods have disadvantages. For example, complex and possibly inefficient protocols are required to transfer lock ownership when one program fails part way through a process and another program continues where the failed program stopped. Additional protocols may be required to identify when all components of the process (which are possibly being performed independently and in parallel) are complete and/or to identify which components remain to be done. Some form of coordination program is therefore required in the known systems.
It is an object of the present invention to provide a method of serialization support which avoids assigning ownership of the process to a particular program, application or computer. This simplifies the programming and avoids or reduces performance problems such as contention. It also avoids the requirement for a coordinating program which also simplifies the programming.
The present invention provides serialization support for a computer system or computer system resource, such as an application program, in order to maintain the sequence and/or consistency of data.
According to a first aspect of the present invention there is provided a method for providing serialization support for a computer system resource which includes processes requiring serialization, the method including: commencing one of the processes requiring serialization; creating a representation of the process and providing the representation on a medium accessible by all components of the computer system to which the serialization requirement applies; deleting the representation when the process is complete; on commencement of a further one of the processes requiring serialization, checking for the existence of the representation on said accessible medium and, if said representation check is positive, controlling serialization of said processes.
Preferably, the representation on the accessible medium includes a serialization token, and the controlling of serialization is performed with reference to the serialization token. This serialization token is preferably allocated to a process by the application program (or other system resource) that the process is part of. Alternatively, the serialization token could be allocated by a serialization controller.
Preferably, the serialization token has a locking protocol mapping to the process representation. A serialization token for a process may be used to prevent other processes commencing during the time that it is in force. Alternatively, the serialization control using serialization tokens may allow multiple processes to commence, but may prevent processes other than the first process from performing certain processing tasks. The serialization token may allow commencement of multiple processes performed on behalf of resource managers within a cooperating group while preventing commencement of other processes.
Preferably, the process representation includes at least one entry, each entry representing an element of the process, wherein each element can be performed independently. Each entry may be created, modified and deleted as the element is processed.
In the event of a failure during a process, the locking protocol is persistent until recovery across all the elements of the representation is complete. Each element of the process is recovered to a consistent state and the corresponding entry in the representation is then deleted, the representation persisting until the last entry is deleted.
Optimally, each element of the representation can be performed and recovered in parallel with the other elements.
Preferably, the serialized processes run on a plurality of subsystems which share a storage space, and the representation is provided in the shared storage space. The shared storage space may be one of a shared database, a shared file system or a coupling means between the subsystems.
In an embodiment, the computer system includes one or more queue manager programs and the serialized processes are message communication processes from application programs connected to the queue manager, each process including at least one unit of work. The computer system may use an application programming interface to indicate to the queue manager the commencement of a process with a serialization token. The elements of the process represented by entries in the representation may include threads of a process, units of work and individual queues on which units of work act. An entry for a unit of work is deleted when the unit of work is rolled forward or back for each queue that it acts on.
Preferably, the computer system is a plurality of subsystems each with a queue manager, the subsystems coupled together by a coupling means which has shared storage space on which the representation is stored in the form of a list structure. In the event of a failure during a process, other queue managers can access the shared storage space to recover the elements of the process independently and in parallel.
According to a second aspect of the present invention there is provided a computer system having serialization support, the computer system comprising one or more components on which serialized processes run, wherein a process which is active has an allocated serialization token, the computer system also comprising a medium which is accessible by the one or more components on which a representation of the active process is created, modified and deleted during the process. The representation is referenced by the serialization token and its existence is used in the control of serialization.
According to a third aspect of the present invention there is provided a method for providing serialization support for a computer system comprising a plurality of subsystems with a shared memory space, the subsystems having a plurality of processes, wherein a process is allocated a serialization token which has a locking protocol mapping to a list structure representing the process in the shared memory space, the locking protocol enabling the plurality of processes to serialize with each other.
According to a fourth aspect of the present invention there is provided a computer program product stored on a computer readable storage medium, comprising computer readable program code means for performing the steps of a method for serializing processes, the method including: commencing one of a set of processes requiring serialization; creating a representation of the process, the representation including a respective serialization token for the process; providing the representation on a medium accessible by all components of the computer system to which the serialization requirement applies; deleting the representation when the process is complete; on commencement of a further one of the processes requiring serialization, checking for the existence of the representation on said accessible medium and, if said representation check is positive, controlling serialization of said processes with reference to said serialization token.